from myelin.Ns import MYELINS

from Reset import Form


class Form(Form):
    
    def createInstance(self, context, node):
        args = context.request.args
        
        eventData = context.event.data
        
        model = context.model
        preferences = context.preferences
                
        nxa = node.xml_append
        nxc = node.xml_create_element
        
        errors = eventData.errors
        e_get = errors.get
        
        #nxa(
        #    nxc(
        #        u'a:title', MYELINS,
        #        content = model.rdf_join('dcTitle')
        #    )
        #)
                
        curNode = self.createLocaleOptions(
            context,
            nxa(
                nxc(
                    u'a:xlocale', MYELINS,
                )
            ),
            preferences['locale']
        )
        e = e_get('xlocale')
        if e:
            curNode.error = e
        
        curNode = self.createThemeOptions(
            context,
            nxa(
                nxc(
                    u'a:xtheme', MYELINS,
                )
            ),
            preferences['locale'],
            preferences['theme']
        )
        e = e_get('xtheme')
        if e:
            curNode.error = e
        
        return node